package com.lc202310;

/**
 * Description:
 *
 * @Create 2023/10/22 23:30
 * @Version 1.0
 */
public class Solution100 {
    public boolean isSameTree(TreeNode p, TreeNode q) {
        return nextTreeNode(p, q);
    }

    private boolean nextTreeNode(TreeNode left, TreeNode right) {
        if (left == null && right == null) {
            return true;
        }
        if (left != null && right != null) {
            return left.val == right.val && nextTreeNode(left.left, right.left) && nextTreeNode(left.right, right.right);
        }
        return false;
    }
}
